﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Facade;
using IronOne.SalesOne.BusinessObjects;
using IronOne.SalesOne.SalesOneWeb;
using System.Text;

namespace IronOne.SalesOne.SalesOneWeb.Collection
{
    public partial class ReceiptDatails : System.Web.UI.Page
    {
        string SOCode;
        string RecNo;
        FinanceFacade finFacad;

        protected void Page_Load(object sender, EventArgs e)
        {
            SOCode = Request.QueryString["SOCode"].ToString();
            RecNo = Request.QueryString["RecNo"].ToString();
            finFacad = new FinanceFacade();

            lblRecNo.Text = SOCode + "-" + RecNo;
            if (!Page.IsPostBack)
            { 
            }

            ShowReceiptDetails(RecNo, SOCode);
        }

        private void ShowReceiptDetails(string recNo, string SOCode)
        {
            List<CollectionTransaction> collections = new List<CollectionTransaction>();
            collections = finFacad.GetReceiptDetails(Convert.ToInt64(recNo), SOCode);

            if (collections.Count > 0)
            {
                lblIDType.Text = collections[0].strIDType;
                lblNIC.Text = collections[0].IdNo;
                lblName.Text = collections[0].strSalutation + (collections[0].strSalutation.EndsWith(".") ? " " : ". ") + collections[0].CustomerName;
                lblAddress.Text = collections[0].Address1 + "," + collections[0].Address2 + "," + collections[0].Address3;
                lblPostCode.Text = collections[0].PostCode;
                lblClientID.Text = collections[0].ClientID;
                lblPayMethod.Text = collections[0].PaymentMethod == "CSH" ? "Cash" : "Cheque";
                lblAmount.Text = collections[0].CollectionAmount.ToString();
                //Suren
                //Sync date was changed back to receipt date
                //2012-03-21
                lblDate.Text = collections[0].ReceiptDate.ToString();
                //lblAgentName.Text = collections[0].AgentSalutation+". "+ collections[0].AgentName;
                lblAgentName.Text = collections[0].AgentName;
            }
        }
    }
}
